package com.test.exam.dao;

import java.util.List;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.test.exam.domain.Example;

@Repository
public class ExampleDao {
	
	private final String EXAMPLE_NS =
			"com.test.exam.mapper.ExampleMapper";
	@Autowired
	private SqlSessionTemplate sqlSessionTemplate;
	
	
	public List<Example> getExamplesByQuestionIdx(int questionIdx){
		return sqlSessionTemplate.selectList(
				EXAMPLE_NS+".getExamplesByQuestionIdx", 
				questionIdx);
	}
	
	
	public int addExample(Example example){
		return sqlSessionTemplate.insert(
				EXAMPLE_NS+".addExample", example);
	}
}
